<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Internet Explorer 8 - Cross-domain Request Code Sample</title>
<script type="text/javascript">
    var xdr;

    function read_data()
    {
        var output = document.getElementById('text_response');
        if(output)
        {
        // To view the responseText on the page, click the Read button. 
            output.innerText = xdr.responseText;
        }

        // The Read button also displays the content type and length of 
        // response in alerts.  
        alert("Content-type: " + xdr.contentType);
        alert("Length: " + xdr.responseText.length);
    }

    function alert_error()
    {
	//
        alert("XDR  1 onerror");
    }

    function alert_timeout()
    {
        alert("XDR ontimeout");
    }
	function OnSuccess() {
		if(xdr)
        {
			alert(xdr.contentType);
			alert("Got 1: " + xdr.responseText);
		}
		else
		{
			alert('null');
		}
	}
    

    function req_abort()
    {
        if(xdr)
        {
            xdr.abort(); // Abort XDR if the Stop button is pressed. 
        }
    }
	
    function req_init()
    {
		var locate = window.location.toString().split("/");
		var href = "?referrer=" + locate[0] + "//" + locate[2];
		alert(href);
		options.Success = AlertLog;
        var url = 
        document.getElementById('input_url').value;
        var timeout = 
            document.getElementById('input_timeout').value;
        if (window.XDomainRequest) // Check whether the browser supports XDR. 
        {
            xdr = new XDomainRequest(); // Create a new XDR object.
            if (xdr)
            {
                // There is an error and the request cannot be completed. 
                // For example, the network is not available.
                xdr.onerror     = alert_error;
                        
                // This event is raised when the request reaches its timeout. 
                xdr.ontimeout   = alert_timeout;
                        
                // When the object starts returning data, the onprogress event 
                // is raised and the data can be retrieved by using responseText.
                xdr.onprogress  = function() {
					alert("XDR onprogress 1");
					alert("Got: " + xdr.responseText);
				};
                       
                // When the object is complete, the onload event is raised and 
                // the responseText ensures the data is available. 
                xdr.onload      = function() {
					alert("XDR onload 1" + xdr.contentType);
					alert("Got: " + xdr.responseText);
				};
                xdr.timeout     = timeout;
                        
                // The URL is preset in the text area. This is passed in the 
                // open call with a get request.
                xdr.open("get", url);
                        
                // The request is then sent to the server.  
                xdr.send();
            }
            else
            {
                alert('Failed to create new XDR object.');
            }
        }
        else
        {
            alert('XDR does not exist.');
        }
    }
//http://113.161.70.82/alpha/Mods/ChartStock/Service/ChartStockService.asmx/GetSercurity?securityID=245&langID=29&FromDate=null&ToDate=null&FrequencyCode=FQ_D01&TimePeriodCode=PD_M01
//http://113.161.70.82/alpha/Mods/News/Service/News.asmx/GetNewsBySecurityID?securityID=300184&pageNumber=1&rowPerPage=10&fromDate=null&toDate=null&frequencyCode=null&timePeriod=PD_M01&relevanceLevel=0
</script>
</head>

<body>

<div class="body">
	<h1>Internet Explorer 8 - Cross-domain Request Demo</h1>
	<form action="">
		<!-- Assign URL and timeout values from their text boxes to variables. -->
		<p>URL:	<input id="input_url" type="text" 
		value="http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/Ajax/xdomain.response.movies.aspx"
		style="width: 700px"></p>
		
		<p>Timeout: <input id="input_timeout" type="text" value="10000"></p>
		
		<p><input onclick="req_init()" type="button" value="Get">&nbsp;&nbsp;&nbsp;
		<input onclick="req_abort()" type="button" value="Abort">&nbsp;&nbsp;&nbsp;
		<input onclick="read_data()" type="button" value="Read"></p>
	</form>
	<div id="text_response">
	</div>
</div>

</body>

</html>